#include "app_buffer.h"
#include <string.h>
#include "log.h"

int main(int argc, char const *argv[])
{
	//0 初始化缓冲区
	buffer_t *buffer = app_buffer_init(1024);

	//1 创建一个字符串 并写入区 
	char *str = "atguigu123";
	app_buffer_write(buffer, str, (u_int8_t)strlen(str));

	char *str2 = "atguigu456";
	app_buffer_write(buffer, str2, (u_int8_t)strlen(str2));

	//2 读取
	char buf[100];
	int read_len= app_buffer_read(buffer, buf, 100);
	log_info("read_len=%d, buf=%.*s", read_len,read_len, buf);

	char buf2[100];
	int read_len2= app_buffer_read(buffer, buf2, 100);
	log_info("read_len=%d, buf=%.*s", read_len2,read_len2, buf2);

	//3 销毁
	app_buffer_destroy(buffer);

	return 0;
}
